package com.nf.db.handler.list;

import com.nf.db.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import static com.nf.db.RowProcessor.DEFAULT_ROWPROCESSOR;

/**
 * 此handler类似于ScalarHandler，只不过是处理多行记录
 */
public class ColumnListHandler<T> extends AbstractListHandler<T> {

    private String columnName;

    public ColumnListHandler(String columnName) {
        this.columnName = columnName;
    }

    @Override
    protected T handleRow(ResultSet rs) throws SQLException {
        return DEFAULT_ROWPROCESSOR.toScalar(rs, this.columnName);
    }
}
